﻿<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">人员管理</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">人员管理</a>
                </li>
                <li class="breadcrumb-item active">人员基础信息</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <div class="row row-lg">
                        <div class="col-md-12">
                            <div class="example-wrap">
                                <h4 class="example-title" style="display:none">添加人员</h4>
                                <div class="example">
                                    <form autocomplete="off">
                                        <div class="row">
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_KeHuXingMing">姓名</label>
                                                <input type="text" class="form-control" id="IptName" name="IptName"
                                                       placeholder="姓名" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">状态</label>
                                                <select id="SelZhuangTai" class="form-control"><option value="在职">在职</option><option value="离职">离职</option></select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">性别</label>
                                                <select id="SelSex" class="form-control"><option value="男">男</option><option value="女">女</option></select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">公司</label>
                                                <select id="SelGongSi" class="form-control"></select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">战区</label>
                                                <select id="SelZhanQu" class="form-control">
                                                    <option value="1">请选择</option>
                                                </select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">战队</label>
                                                <select id="SelZhanDui" class="form-control">
                                                    <option value="1">请选择</option>
                                                </select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">部门</label>
                                                <select id="SelBuMen" class="form-control"></select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">岗位</label>
                                                <select id="SelGangWei" class="form-control"></select>
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_LianXiFangShi">账号</label>
                                                <input type="text" class="form-control" id="IptAccount" name="IptAccount"
                                                       placeholder="账号" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_YiXiangDengJi">密码</label>
                                                <input type="text" class="form-control" id="IptPassWord" name="IptPassWord"
                                                       placeholder="密码" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_LianMingKeHu">年龄</label>
                                                <input type="text" class="form-control" id="IptAge" name="IptAge"
                                                       placeholder="年龄" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_ZhiYeShenFen">联系方式</label>
                                                <input type="text" class="form-control" id="IptLianXiFangShi" name="IptLianXiFangShi"
                                                       placeholder="联系方式" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_JiaoYuChengDu">星级</label>
                                                <input type="text" class="form-control" id="IptXingJi" name="IptXingJi"
                                                       placeholder="星级" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_HunYinZhuangKuang">婚姻状况</label>
                                                <input type="text" class="form-control" id="IptHunYinZhuangKuang" name="IptHunYinZhuangKuang"
                                                       placeholder="婚姻状况" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_HunYinZhuangKuang">微信号</label>
                                                <input type="text" class="form-control" id="IptWeiXinHao" name="IptWeiXinHao"
                                                       placeholder="微信号" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_ShouRuQingKuang">邮箱</label>
                                                <input type="text" class="form-control" id="IptEmail" name="IptEmail"
                                                       placeholder="邮箱" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_GongZuoQuYu">身份证号</label>
                                                <input type="text" class="form-control" id="IptIdCard" name="IptIdCard"
                                                       placeholder="身份证号" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_GongZuoDiZhi">家庭地址</label>
                                                <input type="text" class="form-control" id="IptHomeAddress" name="IptHomeAddress"
                                                       placeholder="家庭地址" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_JuZhuQuYu">学历</label>
                                                <input type="text" class="form-control" id="IptXueLi" name="IptXueLi"
                                                       placeholder="学历" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_JuZhuDiZhi">入职时间</label>
                                                <input type="text" class="form-control" data-plugin="datepicker" data-language="zh-CN" id="IptRuZhiShiJian" name="IptRuZhiShiJian">
                                            </div>
                                            <div class="form-group col-sm-6">
                                                <label class="col-form-label" for="for_YiXiangYongTu">离职时间</label>
                                                <input type="text" class="form-control" data-plugin="datepicker" data-language="zh-CN" id="IptLiZhiShiJian" name="IptLiZhiShiJian">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <button type="button" id="BtnCreate" class="btn btn-primary" onclick="Create();">确定</button>
                                            <button type="button" id="BtnModify" class="btn btn-primary" onclick="Modify();">确定</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#SpanRenYuan").click();
        if (getQuery("Id") != null) {
            GetRenYuan();
            $("#BtnCreate").hide();
            //$("#BtnModify").hide();
        } else {
            BindDpGongSi("");
            $("#BtnModify").hide();
            $("#BtnCreate").hide();
        }
        $('#IptName').bind('input propertychange', function () {
            if ($("#IptName").val() == "") {
                $("#IptName").addClass("is-invalid");
            } else {
                $("#IptName").removeClass("is-invalid");
            }
            var age = /^[1-9][0-9]+$/gi;
            var phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
            var idcard = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
            //if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 && $("#IptAge").val() != "" && age.test($("#IptAge").val()) && $("#IptLianXiFangShi").val() != "" && phone.test($("#IptLianXiFangShi").val()) && $("#IptXingJi").val() != "" && $("#IptIdCard").val() != "" && idcard.test($("#IptIdCard").val())) {
            //    if (getQuery("Id") == null) {
            //        $("#BtnCreate").show();
            //    } else {
            //        $("#BtnModify").show();
            //    }
            //} else {
            //    $("#BtnModify").hide();
            //    $("#BtnCreate").hide();
            //}
            if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 ) {
                if (getQuery("Id") == null) {
                    $("#BtnCreate").show();
                } else {
                    $("#BtnModify").show();
                }
            } else {
                $("#BtnModify").hide();
                $("#BtnCreate").hide();
            }
        })
        $('#IptAccount').bind('input propertychange', function () {
            if ($("#IptAccount").val() == "") {
                $("#IptAccount").addClass("is-invalid");
            } else {
                $("#IptAccount").removeClass("is-invalid");
            }
            var age = /^[1-9][0-9]+$/gi;
            var phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
            var idcard = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
            //if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 && $("#IptAge").val() != "" && age.test($("#IptAge").val()) && $("#IptLianXiFangShi").val() != "" && phone.test($("#IptLianXiFangShi").val()) && $("#IptXingJi").val() != "" && $("#IptIdCard").val() != "" && idcard.test($("#IptIdCard").val())) {
            //    if (getQuery("Id") == null) {
            //        $("#BtnCreate").show();
            //    } else {
            //        $("#BtnModify").show();
            //    }
            //} else {
            //    $("#BtnModify").hide();
            //    $("#BtnCreate").hide();
            //}
            if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5) {
                if (getQuery("Id") == null) {
                    $("#BtnCreate").show();
                } else {
                    $("#BtnModify").show();
                }
            } else {
                $("#BtnModify").hide();
                $("#BtnCreate").hide();
            }
        })
        $('#IptPassWord').bind('input propertychange', function () {
            if ($("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5) {
                $("#IptPassWord").removeClass("is-invalid");
            } else {
                $("#IptPassWord").addClass("is-invalid");
            }
            var age = /^[1-9][0-9]+$/gi;
            var phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
            var idcard = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
            //if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 && $("#IptAge").val() != "" && age.test($("#IptAge").val()) && $("#IptLianXiFangShi").val() != "" && phone.test($("#IptLianXiFangShi").val()) && $("#IptXingJi").val() != "" && $("#IptIdCard").val() != "" && idcard.test($("#IptIdCard").val())) {
            //    if (getQuery("Id") == null) {
            //        $("#BtnCreate").show();
            //    } else {
            //        $("#BtnModify").show();
            //    }
            //} else {
            //    $("#BtnModify").hide();
            //    $("#BtnCreate").hide();
            //}
            if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5) {
                if (getQuery("Id") == null) {
                    $("#BtnCreate").show();
                } else {
                    $("#BtnModify").show();
                }
            } else {
                $("#BtnModify").hide();
                $("#BtnCreate").hide();
            }
        })
        //$('#IptAge').bind('input propertychange', function () {
        //    var r = /^[1-9][0-9]+$/gi;
        //    if ($("#IptAge").val() != "" && r.test($("#IptAge").val())) {
        //        $("#IptAge").removeClass("is-invalid");
        //    } else {
        //        $("#IptAge").addClass("is-invalid");
        //    }
        //    var age = /^[1-9][0-9]+$/gi;
        //    var phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
        //    var idcard = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        //    if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 && $("#IptAge").val() != "" && age.test($("#IptAge").val()) && $("#IptLianXiFangShi").val() != "" && phone.test($("#IptLianXiFangShi").val()) && $("#IptXingJi").val() != "" && $("#IptIdCard").val() != "" && idcard.test($("#IptIdCard").val())) {
        //        if (getQuery("Id") == null) {
        //            $("#BtnCreate").show();
        //        } else {
        //            $("#BtnModify").show();
        //        }
        //    } else {
        //        $("#BtnModify").hide();
        //        $("#BtnCreate").hide();
        //    }
        //})
        //$('#IptLianXiFangShi').bind('input propertychange', function () {
        //    var r = /^1(3|4|5|6|7|8|9)\d{9}$/;
        //    if ($("#IptLianXiFangShi").val() != "" && r.test($("#IptLianXiFangShi").val())) {
        //        $("#IptLianXiFangShi").removeClass("is-invalid");
        //    } else {
        //        $("#IptLianXiFangShi").addClass("is-invalid");
        //    }
        //    var age = /^[1-9][0-9]+$/gi;
        //    var phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
        //    var idcard = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        //    if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 && $("#IptAge").val() != "" && age.test($("#IptAge").val()) && $("#IptLianXiFangShi").val() != "" && phone.test($("#IptLianXiFangShi").val()) && $("#IptXingJi").val() != "" && $("#IptIdCard").val() != "" && idcard.test($("#IptIdCard").val())) {
        //        if (getQuery("Id") == null) {
        //            $("#BtnCreate").show();
        //        } else {
        //            $("#BtnModify").show();
        //        }
        //    } else {
        //        $("#BtnModify").hide();
        //        $("#BtnCreate").hide();
        //    }
        //})
        //$('#IptXingJi').bind('input propertychange', function () {
        //    if ($("#IptXingJi").val() == "") {
        //        $("#IptXingJi").addClass("is-invalid");
        //    } else {
        //        $("#IptXingJi").removeClass("is-invalid");
        //    }
        //    var age = /^[1-9][0-9]+$/gi;
        //    var phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
        //    var idcard = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        //    if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 && $("#IptAge").val() != "" && age.test($("#IptAge").val()) && $("#IptLianXiFangShi").val() != "" && phone.test($("#IptLianXiFangShi").val()) && $("#IptXingJi").val() != "" && $("#IptIdCard").val() != "" && idcard.test($("#IptIdCard").val())) {
        //        if (getQuery("Id") == null) {
        //            $("#BtnCreate").show();
        //        } else {
        //            $("#BtnModify").show();
        //        }
        //    } else {
        //        $("#BtnModify").hide();
        //        $("#BtnCreate").hide();
        //    }
        //})
        //$('#IptIdCard').bind('input propertychange', function () {
        //    var r = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        //    if ($("#IptIdCard").val() != "" && r.test($("#IptIdCard").val())) {
        //        $("#IptIdCard").removeClass("is-invalid");
        //    } else {
        //        $("#IptIdCard").addClass("is-invalid");
        //    }
        //    var age = /^[1-9][0-9]+$/gi;
        //    var phone = /^1(3|4|5|6|7|8|9)\d{9}$/;
        //    var idcard = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
        //    if ($("#IptName").val() != "" && $("#IptAccount").val() != "" && $("#IptPassWord").val() != "" && $("#IptPassWord").val().length > 5 && $("#IptAge").val() != "" && age.test($("#IptAge").val()) && $("#IptLianXiFangShi").val() != "" && phone.test($("#IptLianXiFangShi").val()) && $("#IptXingJi").val() != "" && $("#IptIdCard").val() != "" && idcard.test($("#IptIdCard").val())) {
        //        if (getQuery("Id") == null) {
        //            $("#BtnCreate").show();
        //        } else {
        //            $("#BtnModify").show();
        //        }
        //    } else {
        //        $("#BtnModify").hide();
        //        $("#BtnCreate").hide();
        //    }
        //})
        $('#SelGongSi').bind('input propertychange', function () {
            $("#SelBuMen").empty();
            $("#SelGangWei").empty();
            $.ajax({
                url: "../RenYuan/GetSelBuMen",
                type: "post",
                data: { "GongSiId": $("#SelGongSi").val() },
                dataType: "json",
                success: function (response) {
                    var ddl = $("#SelBuMen");
                    var opt0 = $("<option></option>").text("请选择").val(1);
                    ddl.append(opt0);
                    $(response).each(function (key) {
                        if (response[key].Id.toString() == '1') {
                            var opt = $("<option></option>").text("请选择").val(response[key].Id);
                            ddl.append(opt);
                        } else if (response[key].Id.toString() == "") {
                            var opt = $("<option selected='selected'></option>").text(response[key].BuMenMingCheng).val(response[key].Id);
                            ddl.append(opt);
                        } else {
                            var opt = $("<option></option>").text(response[key].BuMenMingCheng).val(response[key].Id);
                            ddl.append(opt);
                        }
                    })
                    console.log(response);
                }
            });
        })
        $('#SelBuMen').bind('input propertychange', function () {
            $("#SelGangWei").empty();
            $.ajax({
                url: "../RenYuan/GetSelGangWei",
                type: "post",
                data: { "BuMenId": $("#SelBuMen").val() },
                dataType: "json",
                success: function (response) {
                    var ddl = $("#SelGangWei");
                    var opt0 = $("<option></option>").text("请选择").val(1);
                    ddl.append(opt0);
                    $(response).each(function (key) {
                        if (response[key].Id.toString() == '1') {
                            var opt = $("<option></option>").text("请选择").val(response[key].Id);
                            ddl.append(opt);
                        } else if (response[key].Id.toString() == "") {
                            var opt = $("<option selected='selected'></option>").text(response[key].GangWeiMingCheng).val(response[key].Id);
                            ddl.append(opt);
                        } else {
                            var opt = $("<option></option>").text(response[key].GangWeiMingCheng).val(response[key].Id);
                            ddl.append(opt);
                        }
                    })
                }
            });
        })
        $('#SelZhanQu').bind('input propertychange', function () {
            $("#SelZhanDui").empty();
            $.ajax({
                url: "../RenYuan/GetSelZhanDui",
                data: { "ZhanQuId": $("#SelZhanQu").val() },
                type: "post",
                dataType: "json",
                success: function (response) {
                    var ddl = $("#SelZhanDui");
                    var opt0 = $("<option></option>").text("请选择").val(1);
                    ddl.append(opt0);
                    $(response).each(function (key) {
                        if (response[key].id.toString() == '1') {
                            var opt = $("<option></option>").text("请选择").val(response[key].id);
                            ddl.append(opt);
                        } else if (response[key].id.toString() == "") {
                            var opt = $("<option selected='selected'></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        } else {
                            var opt = $("<option></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        }
                    })
                    console.log(response);
                }
            });
        })
    });
    function Create() {
        $.ajax({
            url: "../RenYuan/Create",
            data: {
                "XingMing": $("#IptName").val(),
                "ZhangHao": $("#IptAccount").val(),
                "MiMa": "" + $("#IptPassWord").val() + "",
                "NianLing": $("#IptAge").val(),
                "XingBie": $("#SelSex").val(),
                "LianXiFangShi": $("#IptLianXiFangShi").val(),
                "BuMenId": $("#SelBuMen").val(),
                "GangWeiId": $("#SelGangWei").val(),
                "ZhuangTai": $("#SelZhuangTai").val(),
                "XingJi": $("#IptXingJi").val(),
                "GongSiId": $("#SelGongSi").val(),
                "ZhanQuId": $("#SelZhanQu").val(),
                "ZhanDuiId": $("#SelZhanDui").val(),
                "HunYinZhuangKuang": $("#IptHunYinZhuangKuang").val(),
                "WeiXinHao": $("#IptWeiXinHao").val(),
                "YouXiang": $("#IptEmail").val(),
                "ShenFenZhengHao": $("#IptIdCard").val(),
                "JiaTingDiZhi": $("#IptHomeAddress").val(),
                "XueLi": $("#IptXueLi").val(),
                "RuZhiShiJian": $("#IptRuZhiShiJian").val(),
                "LiZhiShiJian": $("#IptLiZhiShiJian").val()
            },
            cache: false,
            type: "post",
            dataType: "text",
            success: function (response) {
                if (response == "success") {
                    alert("添加成功");
                    //location.href = "../RenYuan/List";
                } else if (response == "error2"){
                    alert("已有该账号!");
                } else {
                    alert("添加失败");
                }
            }
        });
    }
    function Modify() {
        $.ajax({
            url: "../RenYuan/Modify",
            data: {
                "Id": getQuery("Id"),
                "XingMing": $("#IptName").val(),
                "ZhangHao": $("#IptAccount").val(),
                "MiMa": "" + $("#IptPassWord").val() + "",
                "NianLing": $("#IptAge").val(),
                "XingBie": $("#SelSex").val(),
                "LianXiFangShi": $("#IptLianXiFangShi").val(),
                "BuMenId": $("#SelBuMen").val(),
                "GangWeiId": $("#SelGangWei").val(),
                "ZhuangTai": $("#SelZhuangTai").val(),
                "XingJi": $("#IptXingJi").val(),
                "GongSiId": $("#SelGongSi").val(),
                "ZhanQuId": $("#SelZhanQu").val(),
                "ZhanDuiId": $("#SelZhanDui").val(),
                "HunYinZhuangKuang": $("#IptHunYinZhuangKuang").val(),
                "WeiXinHao": $("#IptWeiXinHao").val(),
                "YouXiang": $("#IptEmail").val(),
                "ShenFenZhengHao": $("#IptIdCard").val(),
                "JiaTingDiZhi": $("#IptHomeAddress").val(),
                "XueLi": $("#IptXueLi").val(),
                "RuZhiShiJian": $("#IptRuZhiShiJian").val(),
                "LiZhiShiJian": $("#IptLiZhiShiJian").val()
            },
            cache: false,
            type: "post",
            dataType: "text",
            success: function (response) {
                if (response == "success") {
                    //alert("添加成功");
                    location.href = "../RenYuan/List";
                } else if (response == "error2") {
                    alert("已有该账号!");
                } else {
                    alert("添加失败");
                }
            }
        });
    }
    function BindSel(BuMenId, GangWeiId, GongSiId, ZhanQuId, ZhanDuiId) {
        $.ajax({
            url: "../RenYuan/GetSelGongSi",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelGongSi");
                var opt0 = $("<option></option>").text("请选择").val('0');
                ddl.append(opt0);
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else if (response[key].Id.toString() == GongSiId.toString()) {
                        var opt = $("<option selected='selected'></option>").text(response[key].GongSiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].GongSiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelZhanQu",
            data: { "BuMenId": BuMenId },
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelZhanQu");
                $(response).each(function (key) {
                    console.log(ZhanQuId);
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else if (response[key].Id.toString() == ZhanQuId.toString()) {
                        var opt = $("<option selected='selected'></option>").text(response[key].ZhanQuMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].ZhanQuMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelZhanDui",
            data: { "ZhanQuId": ZhanQuId },
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelZhanDui");
                $(response).each(function (key) {
                    if (response[key].id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].id);
                        ddl.append(opt);
                    } else if (response[key].id.toString() == ZhanDuiId.toString()) {
                        var opt = $("<option selected='selected'></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelBuMen",
            type: "post",
            data: { "GongSiId": GongSiId },
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelBuMen");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else if (response[key].Id.toString() == BuMenId.toString()) {
                        var opt = $("<option selected='selected'></option>").text(response[key].BuMenMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].BuMenMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelGangWei",
            type: "post",
            data: { "BuMenId": BuMenId },
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelGangWei");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else if (response[key].Id.toString() == GangWeiId.toString()) {
                        var opt = $("<option selected='selected'></option>").text(response[key].GangWeiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].GangWeiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
    }
    function BindDpGongSi(GongSiId) {
        $.ajax({
            url: "../RenYuan/GetSelGongSi",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelGongSi");
                var opt0 = $("<option></option>").text("请选择").val('0');
                ddl.append(opt0);
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else if (response[key].Id.toString() == GongSiId.toString()) {
                        var opt = $("<option selected='selected'></option>").text(response[key].GongSiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].GongSiMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelZhanQu",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelZhanQu");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].ZhanQuMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
    }
    function GetRenYuan() {
        $.ajax({
            url: "../RenYuan/ReturnRenYuanJson",
            data: { "Id": getQuery("Id") },
            type: "post",
            dataType: "json",
            success: function (response) {
                console.log(response);
                $(response).each(function (key) {
                    if (response[key].XingBie.toString() == "男") {
                        $("#SelSex option[value='男']").prop("selected", "selected");
                    } else {
                        $("#SelSex option[value='女']").prop("selected", "selected");
                    }


                    $('#IptName').val(response[key].XingMing);
                    $('#IptAccount').val(response[key].ZhangHao);
                    $('#IptPassWord').val(response[key].MiMa);
                    $('#IptAge').val(response[key].NianLing);
                    $('#IptLianXiFangShi').val(response[key].LianXiFangShi);
                    $('#IptXingJi').val(response[key].XingJi);
                    $('#IptHunYinZhuangKuang').val(response[key].HunYinZhuangKuang);
                    $('#IptWeiXinHao').val(response[key].WeiXinHao);
                    $('#IptEmail').val(response[key].YouXiang);
                    $('#IptIdCard').val(response[key].ShenFenZhengHao);
                    $('#IptHomeAddress').val(response[key].JiaTingDiZhi);
                    $('#IptXueLi').val(response[key].XueLi);
                    $('#IptRuZhiShiJian').val(response[key].RuZhiShiJian);
                    $('#IptLiZhiShiJian').val(response[key].LiZhiShiJian);
                    BindSel(response[key].t_GangWeiBiao.t_BuMenBiao.Id, response[key].GangWeiId, response[key].t_GangWeiBiao.t_BuMenBiao.t_GongSiBiao.Id, response[key].t_ZhanDuiBiao.t_ZhanQuBiao.Id, response[key].ZhanDuiId);
                })
            }
        });
    }
    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }
</script>